//
//  BarViewController.m
//  ybUIView
//
//  Created by mac on 15-11-30.
//  Copyright (c) 2015年 1. All rights reserved.
//

#import "BarViewController.h"
#import "ViewController.h"

@interface BarViewController () <UITextFieldDelegate,inDelegate>
{
    UITextField *tfname;
    UITextField *tftel;
}
@end

@implementation BarViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    tfname = [[UITextField alloc]initWithFrame:CGRectMake(16, 0, self.view.frame.size.width , 44)];
    tftel = [[UITextField alloc]initWithFrame:CGRectMake(16, 0, self.view.frame.size.width , 44)];
    tfname.text =self.name;
    tftel.text = self.tel;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(sec:)];
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    [textField resignFirstResponder];
    [self.delegate inname:textField.text];
    return YES;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
    //return [@"姓名",@"电话"][section];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    [cell addSubview:indexPath.section == 0 ? tfname : tftel];
    
    return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @[@"姓名",@"电话"][section];
}


- (void)sec:(UIBarButtonItem *)bar
{
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
